<?php

namespace App\Http\Controllers\Home;

use App\Models\Reply;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests\ReplyRequest;
use Auth;

class RepliesController extends Controller
{
    public function __construct(){
        $this->middleware('auth');
    }

	public function store(ReplyRequest $request,Reply $reply){
        $reply->content = $request->content;
        $reply->user_id = Auth::id();
        $reply->topic_id = $request->topic_id;
        $reply->save();
		// return redirect()->route('replies.show', $reply->id)->with('message', 'Created successfully.');
        return redirect()->to($reply->topic->link())->with('success','评价成功!');
	}

	public function destroy(Reply $reply){
		$this->authorize('destroy', $reply);
		$reply->delete();
		return redirect()->to($reply->topic->link())->with('success', '删除成功');
	}
}